<?php
/*
 * Created on Feb 10, 2011
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
set_time_limit(0);
ini_set("memory_limit","320M");

define("ENTER",chr(13).chr(10));	//--- enter

include_once("../../configure/configure.php");						//--> global var
include_once("Common.php");							//--> Common
include_once("Xml.php");							//--> Xml
include_once("Strings.php");						//--> String utils

include_once("../../lib/impl/CouponImpl.php");
include_once("../../lib/impl/CouponAttributeImpl.php");

$oCommon 	= new Common();							//--> Common
$oXml 		= new Xml();							//--> Xml
$objStrings = new Strings();

$oCouponImpl 	= new CouponImpl(DB_TAG_COUPON);
$oCAttributeImpl= new CouponAttributeImpl(DB_TAG_COUPON);


$sql = "SELECT id, nameId FROM merchant WHERE status = 1";

$allproducts 	= $oCommon->getAllData(DB_TAG_COUPON, $sql);

$oXml->add('url', '', '', 'start');
		
$url = ENTER . 'http://www.hohobb.com';
$oXml->add('loc', '', $url, 'start');
$oXml->add('loc', '', '', 'end');

$oXml->add('url', '', '', 'end');
		
foreach($allproducts as $row){
	$merId 		= $row['id'];
	$merNameId	= $row['nameId'];
	
	$oXml->add('url', '', '', 'start');
	
	$url = ENTER . "http://www.hohobb.com/$merNameId-discount-coupons";
	
	$oXml->add('loc', '', $url, 'start');
	$oXml->add('loc', '', '', 'end');
	
	$oXml->add('url', '', '', 'end');
	
}


$oCoupons = $oCouponImpl->getAll();
		
foreach ($oCoupons as $oCoupon) {
	
	$oXml->add('url', '', '', 'start');
	
	$url = ENTER . "http://www.hohobb.com/coupons/". $oCoupon->getId();
	$oXml->add('loc', '', $url, 'start');
	$oXml->add('loc', '', '', 'end');
	
	$oXml->add('url', '', '', 'end');
}


$oXml->createXml('../../siteMapFiles/googleSiteMap.xml', 'urlset', ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"');
//$oXml->createXml('../../siteMapFiles/googleSiteMap.xml', 'urlset', ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"');

echo "Created file by Crontab"


?>
